/**
 * 
 */
package jmine.tec.utils.version;

import java.io.Serializable;

/**
 * Representa a versao de SCM
 * 
 * @author takeshi
 */
public class SCMRevision implements Serializable {

    public static final SCMRevision NA = new SCMRevision("NA") {

        public String toString() {
            return "NA";
        }

        public boolean equals(Object obj) {
            return this == NA;
        }

        public int hashCode() {
            return System.identityHashCode(this);
        }

        protected Object readResolve() {
            return NA;
        }

    };

    private final String scmRevision;

    /**
     * @param scmRev String
     */
    public SCMRevision(String scmRev) {
        this.scmRevision = scmRev;
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "r" + scmRevision;
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.lang.Object#hashCode()
     */

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((this.scmRevision == null) ? 0 : this.scmRevision.hashCode());
        return result;
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.lang.Object#equals(java.lang.Object)
     */

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (this.getClass() != obj.getClass()) {
            return false;
        }
        SCMRevision other = (SCMRevision) obj;
        if (this.scmRevision == null) {
            if (other.scmRevision != null) {
                return false;
            }
        } else if (!this.scmRevision.equals(other.scmRevision)) {
            return false;
        }
        return true;
    }

}